package com.jpyl.jpMedicalTreatment.view.activity.home;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.jpyl.jpMedicalTreatment.R;
import com.jpyl.jpMedicalTreatment.model.DateOfCheckModel;
import com.jpyl.jpMedicalTreatment.view.activity.BaseActivity;
import com.jpyl.jpMedicalTreatment.view.adapter.CheckDetailsAdapter;
import com.jpyl.jpMedicalTreatment.view.widget.CheckItemPicDialog;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 病人首页-检查日期-详情界面
 * Created by 15697 on 2019/2/27.
 */

public class CheckDetailsActivity extends BaseActivity {
    @BindView(R.id.lv_listLayout)
    ListView lvListLayout;
    String title;
    List<String> list = new ArrayList<>();
    CheckDetailsAdapter adapter;
    DateOfCheckModel.RowsBean bean;
    int pos = -1;
    CheckItemPicDialog dialog;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_list_layout;
    }

    @Override
    public void afterCreate(Bundle savedInstanceState) {
        title = getIntent().getStringExtra("title");
        pos = getIntent().getIntExtra("pos", -1);
        bean = (DateOfCheckModel.RowsBean) getIntent().getSerializableExtra("list");

        mTitleTv.setText(title + "数据");
        switch (pos) {
            case 0:
                //hpv检查数据
                adapter = new CheckDetailsAdapter(getApplicationContext(), getList_1());
                lvListLayout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        if (i == 0) {
                            //就诊结果
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .getDiagnostic(), bean.getDiagnostic_pic());
                            dialog.show();
                        }
                        if (i == 10) {
                            //宫颈
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .isCervix(), bean.isCervix_pic());
                            dialog.show();
                        }
                        if (i == 11) {
                            //tct
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .isTct(), bean.isTct_pic());
                            dialog.show();
                        }
                        if (i == 12) {
                            //阴道镜
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .isColposcopy(), bean.isColposcopy_pic());
                            dialog.show();
                        }
                        if (i == 13) {
                            //E6E7
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .isE6e7(), bean.isE6e7_pic());
                            dialog.show();
                        }
                        if (i == 14) {
                            //hpv型号载重
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .isHpv(), bean.isHpv_pic());
                            dialog.show();
                        }
                    }
                });
                break;
            case 1:
                //hp检查数据
                adapter = new CheckDetailsAdapter(getApplicationContext(), getList_2());
                lvListLayout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        if (i == 2) {
                            //就诊结果
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .getDiagnostic(), bean.getDiagnostic_pic());
                            dialog.show();
                        }
                        if (i == 6) {
                            //hp检测额数据
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .getHp(), bean.getHp_pic());
                            dialog.show();
                        }
                    }
                });
                break;
            case 2:
                //se检查数据
                adapter = new CheckDetailsAdapter(getApplicationContext(), getList_3());
                lvListLayout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                        if (i == 2) {
                            //就诊结果
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .getDiagnostic(), bean.getDiagnostic_pic());
                            dialog.show();
                        }
                        if (i == 6) {
                            //se检测数据
                            dialog = new CheckItemPicDialog(CheckDetailsActivity.this, bean
                                    .getSe(), bean.getSe_pic());
                            dialog.show();
                        }
                    }
                });
                break;
        }
        lvListLayout.setAdapter(adapter);
    }

    //hpv显示样式
    private List<String> getList_1() {
        String[] strings = getResources().getStringArray(R.array.hpvStatus);
        list.add(strings[0] + bean.getDiagnostic());
        list.add(strings[1] + bean.getPast_hospital());
        list.add(strings[2] + bean.getPast_doctor());
        list.add(strings[3] + bean.getPast_doctor());
        list.add(strings[4] + bean.isCur_hospital());
        list.add(strings[5] + bean.isCur_doctor());
        list.add(strings[6] + bean.isCur_doctor());
        list.add(strings[7] + bean.isPeriod());
        list.add(strings[8] + bean.isPregnant());
        list.add(strings[9] + bean.isBirth());
        list.add(strings[10] + bean.isCervix());
        list.add(strings[11] + bean.isTct());
        list.add(strings[12] + bean.isColposcopy());
        list.add(strings[13] + bean.isE6e7());
        list.add(strings[14] + bean.isHpv());
        list.add(strings[15] + bean.isTreatment());
        list.add(strings[16] + bean.isTreatment_period());
        return list;
    }

    //hp显示样式
    private List<String> getList_2() {
        String[] strings = getResources().getStringArray(R.array.hpStatus);
        String s = "否";
        if (bean.isPast_sick()) {
            s = "是";
        }
        list.add(strings[0] + s);
        list.add(strings[1] + bean.getMethod());
        list.add(strings[2] + bean.getDiagnostic());
        list.add(strings[3] + bean.getPast_hospital());
        list.add(strings[4] + bean.getPast_doctor());
        list.add(strings[5] + bean.getPast_doctor());
        list.add(strings[6] + bean.getHp());
        return list;
    }//hp显示样式

    private List<String> getList_3() {
        String[] strings = getResources().getStringArray(R.array.seStatus);
        String s = "否";
        if (bean.isPast_sick()) {
            s = "是";
        }
        list.add(strings[0] + s);
        list.add(strings[1] + bean.getMethod());
        list.add(strings[2] + bean.getDiagnostic());
        list.add(strings[3] + bean.getPast_hospital());
        list.add(strings[4] + bean.getPast_doctor());
        list.add(strings[5] + bean.getPast_doctor());
        list.add(strings[6] + bean.getSe());
        return list;
    }


}
